package com.city.java.feedbacks.pojo.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.time.LocalDateTime;

/**
 * 意见反馈实体类
 */
@Data
public class Feedbacks {
    private Long feedbackId;
    private Long userId;
    private String userName;
    private String content;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createdAt;
    private FeedbackStatus status;

    /**
     * 反馈状态枚举 - 对应数据库 ENUM('pending', 'processed')
     */
    public enum FeedbackStatus {
        pending("pending"),
        processed("processed");

        private final String value;

        FeedbackStatus(String value) {
            this.value = value;
        }

        public String getValue() {
            return value;
        }

        public static FeedbackStatus fromValue(String value) {
            for (FeedbackStatus status : values()) {
                if (status.value.equalsIgnoreCase(value)) {
                    return status;
                }
            }
            throw new IllegalArgumentException("Invalid feedback status: " + value);
        }

        @Override
        public String toString() {
            return this.value;
        }
    }
}
